// //使用 Cargo 新建一个叫做 rectangles 的二进制程序，它获取以像素为单位的长方形的宽度和高度，并计算出长方形的面积。示例 5-8 显示了位于项目的 src/main.rs 中的小程序，它刚刚好实现此功能
// fn main() {
//     let width1 = 30;
//     let height1 = 50;

//     println!(
//         "The area of the rectangle is {} square pixels.",
//         area(width1,height1)
//     );
//     //The area of the rectangle is 1500 square pixel
//     println!("width: {} , height:{}",width1,height1);
//     //width: 30 , height:50
// }


// fn area(width: u32,height: u32)->u32{
//     width*height
// }

// // 使用元组的版本
// fn main() {
//     let rect1 = (30,30);

//     println!("The area of the rectangle is {} square pixels.",
//         area(rect1)
//     )
//     //The area of the rectangle is 900 square pixels.
// }

// fn area(rect:(u32,u32))->u32{
//     rect.0*rect.1
// }

#[derive(Debug)]
struct Rectangele {
    width: u32,
    height: u32,
}

fn main() {
    let rect1 = Rectangele{width:30,height:50};

    println!(
        "The area of the rectangle is {} square pixels.",
        area(&rect1)
    );
    //The area of the rectangle is 1500 square pixels.
    println!("rect1:{:?}",rect1);
    //rect1:Rectangele { width: 30, height: 50 }
    println!("rect1:{:#?}",rect1);
    // rect1:Rectangele {
    //     width: 30,
    //     height: 50,
    // }
}

fn area(rectangle:&Rectangele) ->u32{
    rectangle.width*rectangle.height
}







